package org.fhm.zdte.common.standard;

import org.fhm.zdte.common.pojo.Address;
import org.fhm.zdte.common.pojo.Request;
import org.fhm.zdte.common.protocol.AbstractMessageStandard;

/**
 * The interface <b>IReceiveMessageManager</b>'s implementation is used to manage on during Accept the message.
 *
 * @author 谭波
 * @since 2023/11/28
 */
public interface IReceiveMessageManager {

    /**
     * Initial Receive-Message-Manager.
     *
     * @param messageStandard Packet-Message.
     * @param address         The source address of Packet-Message.
     */
    void initial(AbstractMessageStandard messageStandard, Address address);

    /**
     * Add Sub-Packet-Message to Packet-Message-Buffer.
     *
     * @param messageStandard Packet-Message.
     * @param address         The source address of Packet-Message.
     */
    void addMessageToBuffer(AbstractMessageStandard messageStandard, Address address);

    /**
     * Determine whether all Sub-Packet-Messages are accepted as completed.
     *
     * @param messageNumber Message number that is a 32-digit string of UUID.
     * @return Packaged request.
     */
    Request isCompleteAndGet(String messageNumber);

    /**
     * The cycle task is started, and a completion response occurs.
     *
     * @param messageNumber Message number that is a 32-digit string of UUID.
     * @param address       The source address of Packet-Message.
     */
    void sendCompleteScheduleAck(String messageNumber, Address address);

    /**
     * Cancels the completion of the answering task。
     *
     * @param messageNumber Message number that is a 32-digit string of UUID.
     */
    void cancelCompleteAck(String messageNumber);

    /**
     * Clear the disconnected client Packet-Message-Buffer.
     *
     * @param from The identification of the disconnected client side.
     */
    void clearMessageBuffer(String from);

}
